package com.base.controller;

import com.base.comm.CommContent;
import com.base.po.tbk.TbkChoiceActivity;
import com.base.service.LogsService;
import com.base.service.TbkChoiceActivityService;
import com.base.utils.Produce;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * 添加精选专场
 */
@Controller
@RequestMapping("/admin")
public class add_ChoiceActivity {

	@Autowired
	private LogsService logsService;// log日志
	@Autowired
	private TbkChoiceActivityService tbkChoiceActivityService;

	// 添加分类
	@RequestMapping(value = "/toAddChoiceActivity", method = RequestMethod.POST)
	public @ResponseBody int toAddChoiceActivity(HttpServletRequest request, TbkChoiceActivity tbkChoiceActivity){
		String userid = (String) request.getSession().getAttribute("adminUserId"); // 登录的用户ID
		if (userid == null) return -1; // 未登录

		tbkChoiceActivity.setId(Produce.getUUID());
		tbkChoiceActivity.setParentid(userid); // 代理商ID
		tbkChoiceActivity.setCreatetime(Produce.getNowDate()); // 创建时间
		tbkChoiceActivity.setDatastatus(1); // 状态可用
		return tbkChoiceActivityService.insertSelective(tbkChoiceActivity); // 添加
	}
}
